package org.csu.mypetstore.web.servlets;

import org.csu.mypetstore.domain.Account;
import org.csu.mypetstore.domain.Log;
import org.csu.mypetstore.domain.Order;
import org.csu.mypetstore.service.AccountService;
import org.csu.mypetstore.service.OrderService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.List;

//查看我的日志信息
public class ViewLogServlet extends HttpServlet {
    private static final String MY_LOG = "/WEB-INF/jsp/account/ViewLog.jsp";
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession();
        Account account = (Account)session.getAttribute("account");
        //获得用户的所有log
        AccountService accountService = new AccountService();
        List<Log> logList = accountService.getLOGsByUsername(account.getUsername());

        session.setAttribute("logList",logList);



        request.getRequestDispatcher(MY_LOG).forward(request,response);
    }
}
